class BrowserHistory {
    public:
        vector<string> vs;
        int pos = -1,end = -1;
        BrowserHistory(string homepage) {
            vs.resize(5000);
            pos = 0,end = 0;
            vs[pos] = (homepage);
        }
        
        void visit(string url) {
            vs[++pos] = url;
            end = pos;
        }
        
        string back(int steps) {
            pos = max(pos - steps,0);
            return vs[pos];
        }
        
        string forward(int steps) {
            pos = min(pos + steps,end);
            return vs[pos];
        }
    };
    
    /**
     * Your BrowserHistory object will be instantiated and called as such:
     * BrowserHistory* obj = new BrowserHistory(homepage);
     * obj->visit(url);
     * string param_2 = obj->back(steps);
     * string param_3 = obj->forward(steps);
     */